/**
 @defgroup ACUAS_EPlcd ACUAS Easy Programming LCD
 @code #include "ACUASlcd.h" @endcode
 @brief C macros to easily program the LCD of ACUAS ATmega16/ATmega32 board. 
 @author Thomas Siepmann, Aachen University of Applied Sciences, Germany. Based on the LCD library of Peter Fleury http://jump.to/fleury
 @see http://www.siepmann.fh-aachen.de
*/
/**@{*/

#include "LCD\lcd.h"
#include "LCD\lcd.c"

char lcd_str[21]; // used by LCD_NUMBER

/** 
 *  @name  LCD initialization and user defined characters
 *  User defined characters: start specialchar.exe in the Tools directory to interactively define characters
 */ 
/// Initializes the LCD and clears the screen
#define ACTIVATE_LCD {lcd_init(LCD_DISP_ON);lcd_clrscr();}
/// User defined characters with 1 additional row below (5x8 dots)
#define LCD_DEF(i,a,b,c,d,e,f,g,h) LCDcharDef(i,a,b,c,d,e,f,g,h);

/** 
 *  @name  LCD Output
 */ 
/// Clear LCD screen
#define CLEAR_LCD lcd_clrscr();
/// Set cursor position for the next output
#define LCD_XY(x,y) lcd_gotoxy(((x)-1),((y)-1));
/// Write string at cursor position
#define LCD_TEXT(string) lcd_puts(string);
/// Write integer number at cursor position
#define LCD_NUMBER(v) {itoa( (v),lcd_str,10); lcd_puts(lcd_str);};
/**
 *  @brief   Write double precision number at cursor position.Conversion is done in the format "[-]d.ddd"
 *  @param   v double value to be displayed
 *  @param   w field width of the output string (including the . and the possible sign for negative values)
 *  @param   p number of digits after the decimal sign
 *  @return  none
 */
#define LCD_D_NUMBER(v,w,p) {dtostrf((v),w,p,lcd_str); lcd_puts(lcd_str);};
/// Write 1 character (char) at cursor position
#define LCD_CHAR(c) lcd_putc(c);
/// Switch on the LCD backlight (3-pin-jumper must be in lower position)
#define LCD_BACKLIGHT_OFF {(PORTD = PORTD & ~(1 << 3));}
/// Switch off the LCD backlight
#define LCD_BACKLIGHT_ON {(PORTD = PORTD | (1 << 3));}

/** 
 *  @name  LCD vertical bargraph
 */ 
/// Define 8 user defined characters for bar representation
#define LCD_BAR_V_INIT {LCD_DEF(1,0,0,0,0,0,0,0,31) LCD_DEF(2,0,0,0,0,0,0,31,31) LCD_DEF(3,0,0,0,0,0,31,31,31) LCD_DEF(4,0,0,0,0,31,31,31,31) LCD_DEF(5,0,0,0,31,31,31,31,31) LCD_DEF(6,0,0,31,31,31,31,31,31) LCD_DEF(7,0,31,31,31,31,31,31,31) LCD_DEF(8,31,31,31,31,31,31,31,31)}
/**
 *  @brief   Display a vertical 2 line (16 rows) high bar.
 *  @param   y Value to be displayed
 *  @param   ymin Minimal value indicating the range of y
 *  @param   ymax Maximal value indicating the range of y
 *  @param   x Column where the bar should appear (1 based counting)
 *  @return  none
 */
#define LCD_BAR_V(y,ymin,ymax,x) LCDbargraphV(y,ymin,ymax,x);

#include "ACUASlcd.c"

/**@}*/


